#include "vesaform.h"
#include "ui_vesaform.h"
#include <QKeyEvent>
#include <QSerialPort>
#include <QDebug>
#include "uart.h"

vesaForm::vesaForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::vesaForm)
{
    ui->setupUi(this);
    this->setStyleSheet("background-color: rgb(0, 186, 238);");
    box_sel=NULL;
    QImage *img=GetLogo();
    if(img!=NULL)
        ui->label_Logo->setPixmap(QPixmap::fromImage(*img).scaled(ui->label_Logo->size()));

}

vesaForm::~vesaForm()
{
    delete ui;
}

void vesaForm::keyPressEvent(QKeyEvent *event)
{
    int key=event->key();
    qDebug()<< key;
//  printf("key= %d\n",key);
    if(key==Qt::Key_F12||key==Qt::Key_Exit)
    {
        if(ShowPreWin())
            this->hide();
    }
    else
        if(ShowWin(key,0))
            this->hide();
}

void vesaForm::on_checkBox_clicked()
{
    sendUartCmd_timing(vesa_640x480);
    SelBox(ui->checkBox);
}

void vesaForm::on_checkBox_2_clicked()
{
    sendUartCmd_timing(vesa_800x600);
    SelBox(ui->checkBox_2);
}

void vesaForm::on_checkBox_3_clicked()
{
    sendUartCmd_timing(vesa_1024x768);
    SelBox(ui->checkBox_3);
}

void vesaForm::on_checkBox_5_clicked()
{
    sendUartCmd_timing(vesa_1360x768);
    SelBox(ui->checkBox_5);
}

void vesaForm::on_checkBox_4_clicked()
{
    sendUartCmd_timing(vesa_1280x768);
    SelBox(ui->checkBox_4);
}

void vesaForm::on_checkBox_9_clicked()
{
    sendUartCmd_timing(vesa_1280x960);
    SelBox(ui->checkBox_9);
}

void vesaForm::on_checkBox_8_clicked()
{
    sendUartCmd_timing(vesa_1400x1050);
    SelBox(ui->checkBox_8);
}

void vesaForm::on_checkBox_10_clicked()
{
    sendUartCmd_timing(vesa_1600x1200);
    SelBox(ui->checkBox_10);
}

void vesaForm::on_checkBox_12_clicked()
{
    sendUartCmd_timing(vesa_1920x1200);
    SelBox(ui->checkBox_12);
}
